home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Divers / DinkClass ƒ / DinkClass / DEventHandler.c < prev    next >
Encoding:
Text File  |  1992-12-31  |  3.4 KB  |  158 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        DEventHandler.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Mark Gross
  7.  
  8.     Copyright:    © 1992 by Applied Technical Software, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>    12/31/92    MTG        making the code conditionaly compiled so         that I am
  13.                                     always working with a current         version in either think c
  14.                                     or MPW C++
  15.          <3>    11/14/92    MTG        Bringing the C++ version up to date WRT the ThinkC version.
  16.          <2>     9/20/92    MTG        Bringin this C++ file up to date with the THINK C version
  17.  
  18.     To Do:
  19. */
  20.  
  21. // This is the definition file for the DEventHandler base class
  22. // for the DinkClass library.  It implements the flow of control
  23. // functionality of the typical application.
  24.  
  25. // Derived classes must call these inherited::"Method"
  26. // at the bottom of the derived functions of the same name
  27.  
  28. #include "DEventHandler.h"
  29. #include "DApplication.h"
  30.  
  31. // Define and set the static members for the compiler.
  32. // they will be reset in the main function.
  33.  
  34. DApplication*    DEventHandler::gApplication = NULL;
  35. Boolean        DEventHandler::gPassItOn = TRUE;
  36.  
  37.  
  38. // The DEventHandler constructor supports the list
  39. // mainteance scheam by installing itself into the 
  40. // gApplication::fEventHandlers list.    
  41.  
  42. DEventHandler::DEventHandler(void)
  43. {
  44.     fNextHandler = NULL;
  45.     fAlive = TRUE;
  46.     if(gApplication)// the gApplication is never kept in the list of Handlers...
  47.         gApplication->InstalHandler(this);
  48. }
  49.  
  50. DEventHandler::~DEventHandler(void)
  51. {
  52.  
  53. }
  54.  
  55.     
  56. Boolean DEventHandler::KillMeNext(void)
  57. {
  58.     Boolean Success;
  59.  
  60.     if(fAlive) 
  61.     {
  62.         Success = gApplication->RemoveHandler( this);
  63.         fAlive = FALSE;     // avoid multiple calls to remove handler and other possible sins. 
  64.         return Success;
  65.     }
  66.     return FALSE;
  67. }
  68.  
  69.  
  70.  
  71. void DEventHandler:: HandleNullEvent(EventRecord *theEvent)
  72. {
  73.     if (gPassItOn && fNextHandler)
  74.         fNextHandler->HandleNullEvent(theEvent);
  75. }
  76.  
  77.  
  78. void DEventHandler:: HandleActivateEvt(EventRecord *theEvent)
  79. {
  80.     if (gPassItOn && fNextHandler)
  81.         fNextHandler->HandleActivateEvt(theEvent);
  82. }
  83.  
  84.  
  85. void DEventHandler:: HandleAutoKey(EventRecord *theEvent)
  86. {
  87.     if (gPassItOn && fNextHandler)
  88.         fNextHandler->HandleAutoKey(theEvent);
  89. }
  90.  
  91.  
  92. void DEventHandler:: HandleKeyDown(EventRecord *theEvent)                
  93. {
  94.     if (gPassItOn && fNextHandler)
  95.         fNextHandler->HandleKeyDown(theEvent);
  96. }
  97.  
  98.  
  99. void DEventHandler:: HandleDiskEvt(EventRecord *theEvent)
  100. {
  101.     if (gPassItOn && fNextHandler)
  102.         fNextHandler->HandleDiskEvt(theEvent);
  103. }
  104.  
  105.  
  106. void DEventHandler:: HandleHighLevelEvent(EventRecord *theEvent)
  107. {
  108.     if (gPassItOn && fNextHandler)
  109.         fNextHandler->HandleHighLevelEvent(theEvent);
  110. }
  111.  
  112.  
  113. void DEventHandler:: HandleOSEvent(EventRecord *theEvent)
  114. {
  115.  
  116.     if (gPassItOn && fNextHandler)
  117.         fNextHandler->HandleOSEvent(theEvent);
  118. }
  119.  
  120.  
  121.  
  122. void DEventHandler:: HandleUpdateEvt(EventRecord *theEvent)
  123. {
  124.  
  125.     if (gPassItOn && fNextHandler)
  126.         fNextHandler->HandleUpdateEvt(theEvent);
  127. }
  128.     
  129.  
  130. void DEventHandler::HandleMouseDown(EventRecord *theEvent, short thePart, WindowPtr theWindow)
  131. {
  132.     if (gPassItOn && fNextHandler)
  133.         fNextHandler->HandleMouseDown(theEvent, thePart, theWindow);
  134. }
  135.  
  136. void DEventHandler::HandleMenuChoice(short menuID, short menuItem)
  137. {
  138.     if (gPassItOn && fNextHandler)
  139.         fNextHandler->HandleMenuChoice(menuID, menuItem);
  140. }
  141.  
  142.  
  143. void    DEventHandler::EnableMenuItem(MenuHandle menu, short item, Boolean enable)
  144. {
  145.  
  146.     if (enable) 
  147.         EnableItem(menu, item);
  148.     else
  149.         DisableItem(menu, item);
  150.     
  151. }// 
  152.     
  153. void DEventHandler::SetUpMenues(void)
  154. {
  155.     if (gPassItOn && fNextHandler)
  156.         fNextHandler->SetUpMenues();
  157. }
  158.